/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NET_VPN_TEMPLATE_PROCESSOR_H
#define NET_VPN_TEMPLATE_PROCESSOR_H

#include <cstdint>
#include <unordered_map>
#include "ipsecvpn_config.h"
#include "l2tpvpn_config.h"
#include "sysvpn_config.h"

namespace OHOS {
namespace NetManagerStandard {
// VPN parameters
const std::string KEY_VPN_ADDRESS = "vpn_address_value";
const std::string KEY_VPN_USERNAME = "vpn_username_value";
const std::string KEY_VPN_IPSEC_IDENTIFIER = "vpn_ipsec_identifier_value";
const std::string KEY_VPN_PASSWORD = "vpn_password_value";
const std::string KEY_VPN_IPSEC_SHAREDKEY = "vpn_ipsec_sharedKey_value";

enum {
    OVPN_AUTH_TYPE_TLS,
    OVPN_AUTH_TYPE_PWD,
    OVPN_AUTH_TYPE_TLS_PWD
};

class VpnTemplateProcessor {
public:
    static int32_t BuildConfig(sptr<SysVpnConfig> config);

private:
    static std::string Ipsec2swanCtl(IpsecVpnConfig *config);
    static std::string Ipsec2strongSwan(sptr<SysVpnConfig> &config);
    static std::string Ipsec2Xl2tpd(L2tpVpnConfig *config);
    static std::string Ipsec2L2tpdClient(L2tpVpnConfig *config);
    static std::string Ipsec2IpsecConf(L2tpVpnConfig *config);
    static std::string Ipsec2IpsecSecrets(L2tpVpnConfig *config);
    static void GetIke2IpsecMschapv2SwanCtlConfigTemplate(std::string &config);
    static void GetIke2IpsecPskSwanCtlConfigTemplate(std::string &config);
    static void GetIke2IpsecRsaSwanCtlConfigTemplate(std::string &config);
    static void GetIpsecHybridRsaSwanCtlConfigTemplate(std::string &config);
    static void GetIpsecXauthPskSwanCtlConfigTemplate(std::string &config);
    static void GetIpsecXauthRsaSwanCtlConfigTemplate(std::string &config);
    static std::string GetSwanCtlConfigTemplate(int32_t configType);
    static std::string GetXl2tpdConfigTemplate(int32_t configType);
    static std::string GetOptionL2tpdConfigTemplate(int32_t configType);
    static std::string GetIpsecConfigTemplate(int32_t configType);
    static std::string GetIpsecSecretsConfigTemplate(int32_t configType);
    static std::string GetStrongSwanConfigTemplate(int32_t configType);
    static std::vector<uint8_t> StringToUint8Array(const std::string& str);
    static std::string ReplaceParams(std::string templateContent, const std::unordered_map<std::string, std::string>& params);
};
} // namespace NetManagerStandard
} // namespace OHOS
#endif // NET_VPN_TEMPLATE_PROCESSOR_H
